/*****************************************************************************
State of Aadhaar Survey 2017-2018

Title: 3_General_usage_pub.do
Author: IDinsight
Contact: stateofaadhaar@idinsight.org
Date: 29 August 2018
Data: "SOA2018_nonroster_cleaned_gen.dta"
User-written commands: estout (ssc install estout if not installed)
Description: 	This .do file conducts analysis for the General Usage section
				and produces output tables in "3_General_Usage.rtf".

Contents:
	
	1. Analysis using non roster data
		- Survey set up
		- Tabulations / Proportions / Means
		- Regressions / Hypothesis tests
	
Missing data code:
	.r = refused
	.d = don't know	
*****************************************************************************/

	
* Setting up
	
	version 14
	capture log close
	clear all
	mac drop _all
	set more off
	
	* Please replace "..." below with the correct file path on your computer
	if "`c(os)'"=="MacOSX"{
		global dir "/Users/`c(username)'/.../SOA2018_data_release/"
		}
	else{
		global dir "C:/Users/`c(username)'/.../SOA2018_data_release/"
		}

/*****************************************************************************
1. Analysis using non roster data
*****************************************************************************/

	*** Survey set up

		cd "${dir}/Data_sets/"
		use "SOA2018_nonroster_cleaned_gen.dta", clear

		drop hh_id
		rename master_key hh_id 
		svyset district_id [pweight=weight_resp_adj] || AC_id || ps_id || hh_id || _n
		cd "${dir}/Output_tables/"
		

	***  Tabulations / Proportions / Means
				
			
		* 4.1 How do people use their Aadhaar 
			
			* ad_use_1: Provided a copy of Aadhaar 
			
				eststo clear
				eststo: estpost svy: tab ad_use_1, percent nototal ci
				estadd matrix cil = e(lb)
				estadd matrix ciu = e(ub)
				count if (ad_use_1 ==.d | ad_use_1 ==.r)
				estadd scalar missing  = r(N)
				count if (ad_use_1 ==.e) 
				estadd scalar er  = r(N)
				
					forvalues i = 1/3 {
				display `i' 
				eststo: estpost svy: tab ad_use_1 if state == `i', percent nototal ci
				estadd matrix cil = e(lb)
				estadd matrix ciu = e(ub)
				count if (ad_use_1 ==.d | ad_use_1 ==.r) & state == `i'
				estadd scalar missing  = r(N)
				count if (ad_use_1 ==.e) & state == `i'
				estadd scalar er  = r(N)
					}
				*set trace on
				esttab using "3_General_Usage.rtf", ///
				compress ///
				collabels(none) ///
				eqlabels(none) ///
				label ///
				modelwidth(0) ///
				incelldelimiter(-) ///
				cells(b(fmt(1)) "cil & ciu") ///
				title ("Table 3.1 Percentage of respondents who have used Aadhaar by providing a photocopy of their Aadhaar card (among those who have an Aadhaar)") ///	
				nostar ///
				nonumbers ///
				mtitles ("All three states" "Andhra Pradesh" "Rajasthan" "West Bengal") ///
				nogaps ///
				stats(N missing, fmt(0) label("Number of observations" "Number of missing observations (don't know / refused)")) ///
				nonotes ///
				addnotes("Notes: 95% confidence intervals are under point estimates.") ///
				replace 
				
				eststo clear
			
				
			* ad_use_2: Showed their Aadhaar as a form of identification 
			
				eststo: estpost svy: tab ad_use_2, percent nototal ci
				estadd matrix cil = e(lb)
				estadd matrix ciu = e(ub)
				count if (ad_use_2 ==.d | ad_use_2 ==.r)
				estadd scalar missing  = r(N)
				count if (ad_use_2 ==.e) 
				estadd scalar er  = r(N)
				
					forvalues i = 1/3 {
				display `i' 
				eststo: estpost svy: tab ad_use_2 if state == `i', percent nototal ci
				estadd matrix cil = e(lb)
				estadd matrix ciu = e(ub)
				count if (ad_use_2 ==.d | ad_use_2 ==.r) & state == `i'
				estadd scalar missing  = r(N)
				count if (ad_use_2 ==.e) & state == `i'
				estadd scalar er  = r(N)
					}
				*set trace on
				esttab using "3_General_Usage.rtf", ///
				compress ///
				collabels(none) ///
				eqlabels(none) ///
				label ///
				modelwidth(0) ///
				incelldelimiter(-) ///
				cells(b(fmt(1)) "cil & ciu") ///
				title ("Table 3.2 Percentage of respondents who have used Aadhaar by showing the card itself (among those who have an Aadhaar)") ///	
				nostar ///
				nonumbers ///
				mtitles ("All three states" "Andhra Pradesh" "Rajasthan" "West Bengal") ///
				nogaps ///
				stats(N missing, fmt(0) label("Number of observations" "Number of missing observations (don't know / refused)")) ///
				nonotes ///
				addnotes("Notes: 95% confidence intervals are under point estimates.") ///
				append 
				
				eststo clear
				
			* ad_use_3: Used their fingerprint on a digital machine 
				
				eststo: estpost svy: tab ad_use_3, percent nototal ci
				estadd matrix cil = e(lb)
				estadd matrix ciu = e(ub)
				count if (ad_use_3 ==.d | ad_use_3 ==.r)
				estadd scalar missing  = r(N)
				count if (ad_use_3 ==.e) 
				estadd scalar er  = r(N)
				
					forvalues i = 1/3 {
				display `i' 
				eststo: estpost svy: tab ad_use_3 if state == `i', percent nototal ci
				estadd matrix cil = e(lb)
				estadd matrix ciu = e(ub)
				count if (ad_use_3 ==.d | ad_use_3 ==.r) & state == `i'
				estadd scalar missing  = r(N)
				count if (ad_use_3 ==.e) & state == `i'
				estadd scalar er  = r(N)
					}
				*set trace on
				esttab using "3_General_Usage.rtf", ///
				compress ///
				collabels(none) ///
				eqlabels(none) ///
				label ///
				modelwidth(0) ///
				incelldelimiter(-) ///
				cells(b(fmt(1)) "cil & ciu") ///
				title ("Table 3.3 Percentage of respondents who have used Aadhaar via fingerprint authentication (among those who have an Aadhaar)") ///	
				nostar ///
				nonumbers ///
				mtitles ("All three states" "Andhra Pradesh" "Rajasthan" "West Bengal") ///
				nogaps ///
				stats(N missing, fmt(0) label("Number of observations" "Number of missing observations (don't know / refused)")) ///
				nonotes ///
				addnotes("Notes: 95% confidence intervals are under point estimates.") ///
				append 
				
				eststo clear
				
			* ad_use_4: Used their iris on a digital machine 
			
				eststo: estpost svy: tab ad_use_4, percent nototal ci
				estadd matrix cil = e(lb)
				estadd matrix ciu = e(ub)
				count if (ad_use_4 ==.d | ad_use_4 ==.r)
				estadd scalar missing  = r(N)
				count if (ad_use_4 ==.e) 
				estadd scalar er  = r(N)
				
					forvalues i = 1/3 {
				display `i' 
				eststo: estpost svy: tab ad_use_4 if state == `i', percent nototal ci
				estadd matrix cil = e(lb)
				estadd matrix ciu = e(ub)
				count if (ad_use_4 ==.d | ad_use_4 ==.r) & state == `i'
				estadd scalar missing  = r(N)
				count if (ad_use_4 ==.e) & state == `i'
				estadd scalar er  = r(N)
					}
				*set trace on
				esttab using "3_General_Usage.rtf", ///
				compress ///
				collabels(none) ///
				eqlabels(none) ///
				label ///
				modelwidth(0) ///
				incelldelimiter(-) ///
				cells(b(fmt(1)) "cil & ciu") ///
				title ("Table 3.4 Percentage of respondents who have used Aadhaar via iris authentication (among those who have an Aadhaar)") ///	
				nostar ///
				nonumbers ///
				mtitles ("All three states" "Andhra Pradesh" "Rajasthan" "West Bengal") ///
				nogaps ///
				stats(N missing, fmt(0) label("Number of observations" "Number of missing observations (don't know / refused)")) ///
				nonotes ///
				addnotes("Notes: 95% confidence intervals are under point estimates.") ///
				append 
				
				eststo clear
				
			* ad_use_5: Used the OTP sent to their mobile registered with Aadhaar 
			
				eststo: estpost svy: tab ad_use_5, percent nototal ci
				estadd matrix cil = e(lb)
				estadd matrix ciu = e(ub)
				count if (ad_use_5 ==.d | ad_use_5 ==.r)
				estadd scalar missing  = r(N)
				count if (ad_use_5 ==.e) 
				estadd scalar er  = r(N)
				
					forvalues i = 1/3 {
				display `i' 
				eststo: estpost svy: tab ad_use_5 if state == `i', percent nototal ci
				estadd matrix cil = e(lb)
				estadd matrix ciu = e(ub)
				count if (ad_use_5 ==.d | ad_use_5 ==.r) & state == `i'
				estadd scalar missing  = r(N)
				count if (ad_use_5 ==.e) & state == `i'
				estadd scalar er  = r(N)
					}
				*set trace on
				esttab using "3_General_Usage.rtf", ///
				compress ///
				collabels(none) ///
				eqlabels(none) ///
				label ///
				modelwidth(0) ///
				incelldelimiter(-) ///
				cells(b(fmt(1)) "cil & ciu") ///
				title ("Table 3.5 Percentage of respondents who have used Aadhaar via one-time password authentication (among those who have an Aadhaar)") ///	
				nostar ///
				nonumbers ///
				mtitles ("All three states" "Andhra Pradesh" "Rajasthan" "West Bengal") ///
				nogaps ///
				stats(N missing, fmt(0) label("Number of observations" "Number of missing observations (don't know / refused)")) ///
				nonotes ///
				addnotes("Notes: 95% confidence intervals are under point estimates. One-time password (OTP) authentication refers to a temporary code sent to the mobile phone number registered with an individual's Aadhaar.") ///
				append 
				
				eststo clear
			
			* ad_use_6: Have not used their Aadhaar
			
				eststo: estpost svy: tab ad_use_6, percent nototal ci
				estadd matrix cil = e(lb)
				estadd matrix ciu = e(ub)
				count if (ad_use_6 ==.d | ad_use_6 ==.r)
				estadd scalar missing  = r(N)
				count if (ad_use_6 ==.e) 
				estadd scalar er  = r(N)
				
					forvalues i = 1/3 {
				display `i' 
				eststo: estpost svy: tab ad_use_6 if state == `i', percent nototal ci
				estadd matrix cil = e(lb)
				estadd matrix ciu = e(ub)
				count if (ad_use_6 ==.d | ad_use_6 ==.r) & state == `i'
				estadd scalar missing  = r(N)
				count if (ad_use_6 ==.e) & state == `i'
				estadd scalar er  = r(N)
					}
				*set trace on
				esttab using "3_General_Usage.rtf", ///
				compress ///
				collabels(none) ///
				eqlabels(none) ///
				label ///
				modelwidth(0) ///
				incelldelimiter(-) ///
				cells(b(fmt(1)) "cil & ciu") ///
				title ("Table 3.6 Percentage of respondents who have not used their Aadhaar (among those who have an Aadhaar)") ///	
				nostar ///
				nonumbers ///
				mtitles ("All three states" "Andhra Pradesh" "Rajasthan" "West Bengal") ///
				nogaps ///
				stats(N missing, fmt(0) label("Number of observations" "Number of missing observations (don't know / refused)")) ///
				nonotes ///
				addnotes("Notes: 95% confidence intervals are under point estimates.") ///
				append 
				
				eststo clear
			
			
		* 4.2 Awareness levels: fingerprint authentication +  Irirs Authentication + OTP Authentication + Overall Awareness
			
			* ad_fprintaware_all 
			
				eststo: estpost svy: tab ad_fprintaware_all, percent nototal ci
				estadd matrix cil = e(lb)
				estadd matrix ciu = e(ub)
				count if (ad_fprintaware_all ==.d | ad_fprintaware_all ==.r)
				estadd scalar missing  = r(N)
				count if (ad_fprintaware_all ==.e) 
				estadd scalar er  = r(N)
				
					forvalues i = 1/3 {
				display `i' 
				eststo: estpost svy: tab ad_fprintaware_all if state == `i', percent nototal ci
				estadd matrix cil = e(lb)
				estadd matrix ciu = e(ub)
				count if (ad_fprintaware_all ==.d | ad_fprintaware_all ==.r) & state == `i'
				estadd scalar missing  = r(N)
				count if (ad_fprintaware_all ==.e) & state == `i'
				estadd scalar er  = r(N)
					}
				*set trace on
				esttab using "3_General_Usage.rtf", ///
				compress ///
				collabels(none) ///
				eqlabels(none) ///
				label ///
				modelwidth(0) ///
				incelldelimiter(-) ///
				cells(b(fmt(1)) "cil & ciu") ///
				title ("Table 3.7 Percentage of respondents aware of fingerprint authentication available with Aadhaar (among those who have an Aadhaar)") ///	
				nostar ///
				nonumbers ///
				mtitles ("All three states" "Andhra Pradesh" "Rajasthan" "West Bengal") ///
				nogaps ///
				stats(N missing, fmt(0) label("Number of observations" "Number of missing observations (don't know / refused)")) ///
				nonotes ///
				addnotes("Notes: 95% confidence intervals are under point estimates." ///
				"In the survey we asked the question about awareness only to respondents who had not used this feature. In this analysis we combine respondents who said they were aware of the feature in the survey and those who had used it.")	///
				append 
				
				eststo clear
			
			* ad_irisaware_all
			
				eststo: estpost svy: tab ad_irisaware_all, percent nototal ci
				estadd matrix cil = e(lb)
				estadd matrix ciu = e(ub)
				count if (ad_irisaware_all ==.d | ad_irisaware_all ==.r)
				estadd scalar missing  = r(N)
				count if (ad_irisaware_all ==.e) 
				estadd scalar er  = r(N)
				
					forvalues i = 1/3 {
				display `i' 
				eststo: estpost svy: tab ad_irisaware_all if state == `i', percent nototal ci
				estadd matrix cil = e(lb)
				estadd matrix ciu = e(ub)
				count if (ad_irisaware_all ==.d | ad_irisaware_all ==.r) & state == `i'
				estadd scalar missing  = r(N)
				count if (ad_irisaware_all ==.e) & state == `i'
				estadd scalar er  = r(N)
					}
				*set trace on
				esttab using "3_General_Usage.rtf", ///
				compress ///
				collabels(none) ///
				eqlabels(none) ///
				label ///
				modelwidth(0) ///
				incelldelimiter(-) ///
				cells(b(fmt(1)) "cil & ciu") ///
				title ("Table 3.8 Percentage of respondents aware of iris authentication available with Aadhaar (among those who have an Aadhaar)") ///	
				nostar ///
				nonumbers ///
				mtitles ("All three states" "Andhra Pradesh" "Rajasthan" "West Bengal") ///
				nogaps ///
				stats(N missing, fmt(0) label("Number of observations" "Number of missing observations (don't know / refused)")) ///
				nonotes ///
				addnotes("Notes: 95% confidence intervals are under point estimates." ///
				"In the survey we asked the question about awareness only to respondents who had not used this feature. In this analysis we combine respondents who said they were aware of the feature in the survey and those who had used it.")	///
				append	
				
				eststo clear
			
			* ad_otpaware_all
			
				eststo: estpost svy: tab ad_otpaware_all, percent nototal ci
				estadd matrix cil = e(lb)
				estadd matrix ciu = e(ub)
				count if (ad_otpaware_all ==.d | ad_otpaware_all ==.r)
				estadd scalar missing  = r(N)
				count if (ad_otpaware_all ==.e) 
				estadd scalar er  = r(N)
				
					forvalues i = 1/3 {
				display `i' 
				eststo: estpost svy: tab ad_otpaware_all if state == `i', percent nototal ci
				estadd matrix cil = e(lb)
				estadd matrix ciu = e(ub)
				count if (ad_otpaware_all ==.d | ad_otpaware_all ==.r) & state == `i'
				estadd scalar missing  = r(N)
				count if (ad_otpaware_all ==.e) & state == `i'
				estadd scalar er  = r(N)
					}
				*set trace on
				esttab using "3_General_Usage.rtf", ///
				compress ///
				collabels(none) ///
				eqlabels(none) ///
				label ///
				modelwidth(0) ///
				incelldelimiter(-) ///
				cells(b(fmt(1)) "cil & ciu") ///
				title ("Table 3.9 Percentage of respondents aware of OTP authentication available with Aadhaar (among those who have an Aadhaar)") ///	
				nostar ///
				nonumbers ///
				mtitles ("All three states" "Andhra Pradesh" "Rajasthan" "West Bengal") ///
				nogaps ///
				stats(N missing, fmt(0) label("Number of observations" "Number of missing observations (don't know / refused)")) ///
				nonotes ///
				addnotes("Notes: 95% confidence intervals are under point estimates." ///
				"In the survey we asked the question about awareness only to respondents who had not used this feature. In this analysis we combine respondents who said they were aware of the feature in the survey and those who had used it.")	///
				append	
				
				eststo clear
			
				
			* ad_aware_all
			
				eststo: estpost svy: tab ad_aware_all, percent nototal ci
				estadd matrix cil = e(lb)
				estadd matrix ciu = e(ub)
				count if (ad_aware_all ==.d | ad_aware_all ==.r | ad_aware_all == .m)
				estadd scalar missing  = r(N)
				count if (ad_aware_all ==.e) 
				estadd scalar er  = r(N)
				
					forvalues i = 1/3 {
				display `i' 
				eststo: estpost svy: tab ad_aware_all if state == `i', percent nototal ci
				estadd matrix cil = e(lb)
				estadd matrix ciu = e(ub)
				count if (ad_aware_all ==.d | ad_aware_all ==.r | ad_aware_all == .m) & state == `i'
				estadd scalar missing  = r(N)
				count if (ad_aware_all ==.e) & state == `i'
				estadd scalar er  = r(N)
					}
				*set trace on
				esttab using "3_General_Usage.rtf", ///
				compress ///
				collabels(none) ///
				eqlabels(none) ///
				label ///
				modelwidth(0) ///
				incelldelimiter(-) ///
				cells(b(fmt(1)) "cil & ciu") ///
				title ("Table 3.10 Percentage of respondents aware of all authentication mechanisms available with Aadhaar (among those who have an Aadhaar)") ///	
				nostar ///
				nonumbers ///
				mtitles ("All three states" "Andhra Pradesh" "Rajasthan" "West Bengal") ///
				nogaps ///
				stats(N missing, fmt(0) label("Number of observations" "Number of missing observations (don't know / refused)")) ///
				nonotes ///
				addnotes("Notes: 95% confidence intervals are under point estimates."  ///
				"In the survey we asked the questions about awareness only to respondents who had not used these features. In this analysis we combine respondents who said they were aware of the features in the survey and those who had used them.")	///
				append	
				
				eststo clear

				
	***  Regressions / Hypothesis tests

		
		* Variable: ad_fprintaware_all 
		
			* Pooled
		
				eststo clear
				local regressors `" "sc_cat st_cat" rel_muslim resp_female resp_noschool resp_above60"'
				local j = 1
				foreach var in `regressors'{
					qui svy: regress ad_fprintaware_all `var'
					gen sample = e(sample)
					count if (ad_fprintaware_all ==.d | ad_fprintaware_all ==.r) 
					loc miss = r(N)
					count if (ad_fprintaware_all ==.e) 
					loc errors = r(N)
					
					preserve
					keep if sample == 1
					svy: mean `var'
					if `j++'==1{
						loc x1 = _b[sc_cat] 
						loc x2 = _b[st_cat]
					}
					else{
						loc x1 = _b[`var']
						loc x2 = .
					}
					svy: mean ad_fprintaware_all
					loc y1 = _b[ad_fprintaware_all]
					eststo: svy: regress ad_fprintaware_all `var'
					estadd scalar missing = `miss'
					estadd scalar errors = `errors'
					estadd scalar y = `y1'
					estadd scalar x = `x1'
					estadd scalar z = `x2'
					restore
					drop sample
				}
				esttab using "3_General_Usage.rtf", ///
					compress ///
					eqlabels(none) ///
					label ///
					title ("Table 3.11.1 Hypothesis tests of differences in levels of awareness of fingerprint authentication for members of different vulnerable communities [All three states]") ///	
					coeflabels (sc_cat "SC respondent" st_cat "ST respondent" rel_muslim "Muslim respondent" resp_noschool  "Respondent has not attended school" resp_female "Female respondent" resp_above60 "Respondent above age 60") ///
					mtitles ("Aware of fingerprint" "Aware of fingerprint" "Aware of fingerprint" "Aware of fingerprint" "Aware of fingerprint" "Aware of fingerprint" "Aware of fingerprint") ///
					p ///
					star (* 0.1 ** 0.05 *** 0.01) ///
					lines ///
					b (3) ///
					p (2) ///
					nogaps ///
					stats(N r2 y, fmt(0 3 3) label("Number of observations" "R-squared" "Mean of dependent variable")) ///			nonotes ///
					addnotes("Notes: p-values in parentheses, with ***, **, * indicating significance at 1, 5 and 10%. No correction for multiple hypothesis testing has been applied to the results in the table." ///
					"We test the null hypotheses that there are no differences in the likelihood of being aware of this authentication mechanism between vulnerable respondents and other respondents, with vulnerability being proxied by each of the categories above. Each column presents coefficients from a regression of the outcome variable on a dummy variable for the corresponding category and a constant. Hence we separately examine whether each individual type above has a different likelihood of being aware of this authentication mechanism compared to all other individuals (i.e. all those not in the specified type).")	///
					append
					loc option append
				eststo clear		
		
			* By state 
			
				tokenize `" "Andhra Pradesh" "Rajasthan" "West Bengal" "'
				forv i = 1/3{
					eststo clear
					local regressors `" "sc_cat st_cat" rel_muslim resp_female resp_noschool resp_above60"'
					local j = 1
					foreach var in `regressors'{
						qui svy: regress ad_fprintaware_all `var' if state == `i'
						gen sample = e(sample)
						count if (ad_fprintaware_all ==.d | ad_fprintaware_all ==.r) & state == `i'
						loc miss = r(N)
						count if (ad_fprintaware_all ==.e) & state == `i'
						loc errors = r(N)
						
						preserve
						keep if sample == 1
						svy: mean `var'
						if `j++'==1{
							loc x1 = _b[sc_cat] 
							loc x2 = _b[st_cat]
						}
						else{
							loc x1 = _b[`var']
							loc x2 = .
						}
						svy: mean ad_fprintaware_all
						loc y1 = _b[ad_fprintaware_all]
						eststo: svy: regress ad_fprintaware_all `var'
						estadd scalar missing = `miss'
						estadd scalar errors = `errors'
						estadd scalar y = `y1'
						estadd scalar x = `x1'
						estadd scalar z = `x2'
						restore
						drop sample
					}
					local k = `i' + 1
				esttab using "3_General_Usage.rtf", ///
						compress ///
						eqlabels(none) ///
						label ///
						title ("Table 3.11.`k' Hypothesis tests of differences in levels of awareness of fingerprint authentication for members of different vulnerable communities [State: ``i++'']") ///	
						coeflabels (sc_cat "SC respondent" st_cat "ST respondent" rel_muslim "Muslim respondent" resp_noschool  "Respondent has not attended school" resp_female "Female respondent" resp_above60 "Respondent above age 60") ///
						mtitles ("Aware of fingerprint" "Aware of fingerprint" "Aware of fingerprint" "Aware of fingerprint" "Aware of fingerprint" "Aware of fingerprint" "Aware of fingerprint") ///
						p ///
						star (* 0.1 ** 0.05 *** 0.01) ///
						lines ///
						b (3) ///
						p (2) ///
						nogaps ///
						stats(N r2 y, fmt(0 3 3) label("Number of observations" "R-squared" "Mean of dependent variable")) ///			nonotes ///
						nonotes ///
						addnotes("Notes: p-values in parentheses, with ***, **, * indicating significance at 1, 5 and 10%. No correction for multiple hypothesis testing has been applied to the results in the table." ///
						"See footnote to Table 3.11.1 for a description of the hypotheses tested here.")	///
						append
						loc option append
				}		
				eststo clear	
		
		
		* Variable: ad_irisaware_all 
		
			* Pooled
			
				eststo clear
				local regressors `" "sc_cat st_cat" rel_muslim resp_female resp_noschool resp_above60"'
				local j = 1
				foreach var in `regressors'{
					qui svy: regress ad_irisaware_all `var'
					gen sample = e(sample)
					count if (ad_irisaware_all ==.d | ad_irisaware_all ==.r) 
					loc miss = r(N)
					count if (ad_irisaware_all ==.e) 
					loc errors = r(N)
					
					preserve
					keep if sample == 1
					svy: mean `var'
					if `j++'==1{
						loc x1 = _b[sc_cat] 
						loc x2 = _b[st_cat]
					}
					else{
						loc x1 = _b[`var']
						loc x2 = .
					}
					svy: mean ad_irisaware_all
					loc y1 = _b[ad_irisaware_all]
					eststo: svy: regress ad_irisaware_all `var'
					estadd scalar missing = `miss'
					estadd scalar errors = `errors'
					estadd scalar y = `y1'
					estadd scalar x = `x1'
					estadd scalar z = `x2'
					restore
					drop sample
				}
				esttab using "3_General_Usage.rtf", ///
					compress ///
					eqlabels(none) ///
					label ///
					title ("Table 3.12.1 Hypothesis tests of differences in levels of awareness of iris authentication for members of different vulnerable communities [State: ``i++'']") ///	
					coeflabels (sc_cat "SC respondent" st_cat "ST respondent" rel_muslim "Muslim respondent" resp_noschool  "Respondent has not attended school" resp_female "Female respondent" resp_above60 "Respondent above age 60") ///
					mtitles ("Aware of iris" "Aware of iris" "Aware of iris" "Aware of iris" "Aware of iris" "Aware of iris") ///
					p ///
					star (* 0.1 ** 0.05 *** 0.01) ///
					lines ///
					b (3) ///
					p (2) ///
					nogaps ///
					stats(N r2 y, fmt(0 3 3) label("Number of observations" "R-squared" "Mean of dependent variable")) ///			nonotes ///
					nonotes ///
					addnotes("Notes: p-values in parentheses, with ***, **, * indicating significance at 1, 5 and 10%. No correction for multiple hypothesis testing has been applied to the results in the table." ///
					"We test the null hypotheses that there are no differences in the likelihood of being aware of this authentication mechanism between vulnerable respondents and other respondents, with vulnerability being proxied by each of the categories above. Each column presents coefficients from a regression of the outcome variable on a dummy variable for the corresponding category and a constant. Hence we separately examine whether each individual type above has a different likelihood of being aware of this authentication mechanism compared to all other individuals (i.e. all those not in the specified type).")	///
					append
					loc option append
				eststo clear	
			
		
			* By state 
		
				tokenize `" "Andhra Pradesh" "Rajasthan" "West Bengal" "'
				forv i = 1/3{
					eststo clear
					local regressors `" "sc_cat st_cat" rel_muslim resp_female resp_noschool resp_above60"'
					local j = 1
					foreach var in `regressors'{
						qui svy: regress ad_irisaware_all `var' if state == `i'
						gen sample = e(sample)
						count if (ad_irisaware_all ==.d | ad_irisaware_all ==.r) & state == `i'
						loc miss = r(N)
						count if (ad_irisaware_all ==.e) & state == `i'
						loc errors = r(N)
						
						preserve
						keep if sample == 1
						svy: mean `var'
						if `j++'==1{
							loc x1 = _b[sc_cat] 
							loc x2 = _b[st_cat]
						}
						else{
							loc x1 = _b[`var']
							loc x2 = .
						}
						svy: mean ad_irisaware_all
						loc y1 = _b[ad_irisaware_all]
						eststo: svy: regress ad_irisaware_all `var'
						estadd scalar missing = `miss'
						estadd scalar errors = `errors'
						estadd scalar y = `y1'
						estadd scalar x = `x1'
						estadd scalar z = `x2'
						restore
						drop sample
					}
					local k = `i' + 1
				esttab using "3_General_Usage.rtf", ///
						compress ///
						eqlabels(none) ///
						label ///
						title ("Table 3.12.`k' Hypothesis tests of differences in levels of awareness of iris authentication for members of different vulnerable communities [State: ``i++'']") ///	
						coeflabels (sc_cat "SC respondent" st_cat "ST respondent" rel_muslim "Muslim respondent" resp_noschool  "Respondent has not attended school" resp_female "Female respondent" resp_above60 "Respondent above age 60") ///
						mtitles ("Aware of iris" "Aware of iris" "Aware of iris" "Aware of iris" "Aware of iris" "Aware of iris") ///
						p ///
						star (* 0.1 ** 0.05 *** 0.01) ///
						lines ///
						b (3) ///
						p (2) ///
						nogaps ///
						stats(N r2 y, fmt(0 3 3) label("Number of observations" "R-squared" "Mean of dependent variable")) ///			nonotes ///
						nonotes ///
						addnotes("Notes: p-values in parentheses, with ***, **, * indicating significance at 1, 5 and 10%. No correction for multiple hypothesis testing has been applied to the results in the table." ///
						"See footnote to Table 3.12.1 for a description of the hypotheses tested here.")	///
						append
						loc option append
				}		
				eststo clear	
			
		
		* Variable: ad_otpaware_all
		
			* Pooled
			
				eststo clear
				local regressors `" "sc_cat st_cat" rel_muslim resp_female resp_noschool resp_above60"'
				local j = 1
				foreach var in `regressors'{
					qui svy: regress ad_otpaware_all `var'
					gen sample = e(sample)
					count if (ad_otpaware_all ==.d | ad_otpaware_all ==.r) 
					loc miss = r(N)
					count if (ad_otpaware_all ==.e) 
					loc errors = r(N)
					
					preserve
					keep if sample == 1
					svy: mean `var'
					if `j++'==1{
						loc x1 = _b[sc_cat] 
						loc x2 = _b[st_cat]
					}
					else{
						loc x1 = _b[`var']
						loc x2 = .
					}
					svy: mean ad_otpaware_all
					loc y1 = _b[ad_otpaware_all]
					eststo: svy: regress ad_otpaware_all `var'
					estadd scalar missing = `miss'
					estadd scalar errors = `errors'
					estadd scalar y = `y1'
					estadd scalar x = `x1'
					estadd scalar z = `x2'
					restore
					drop sample
				}
				esttab using "3_General_Usage.rtf", ///
					compress ///
					eqlabels(none) ///
					label ///
					title ("Table 3.13.1 Hypothesis tests of differences in levels of awareness of OTP authentication for members of different vulnerable communities [All three states]") ///	
					coeflabels (sc_cat "SC respondent" st_cat "ST respondent" rel_muslim "Muslim respondent" resp_noschool  "Respondent has not attended school" resp_female "Female respondent" resp_above60 "Respondent above age 60") ///
					mtitles ("Aware of OTP" "Aware of OTP" "Aware of OTP" "Aware of OTP" "Aware of OTP" "Aware of OTP" "Aware of OTP") ///
					p ///
					star (* 0.1 ** 0.05 *** 0.01) ///
					lines ///
					b (3) ///
					p (2) ///
					nogaps ///
					stats(N r2 y, fmt(0 3 3) label("Number of observations" "R-squared" "Mean of dependent variable")) ///			nonotes ///
					nonotes ///
					addnotes("Notes: p-values in parentheses, with ***, **, * indicating significance at 1, 5 and 10%. No correction for multiple hypothesis testing has been applied to the results in the table." ///
					"We test the null hypotheses that there are no differences in the likelihood of being aware of this authentication mechanism between vulnerable respondents and other respondents, with vulnerability being proxied by each of the categories above. Each column presents coefficients from a regression of the outcome variable on a dummy variable for the corresponding category and a constant. Hence we separately examine whether each individual type above has a different likelihood of being aware of this authentication mechanism compared to all other individuals (i.e. all those not in the specified type).")	///
					append
					loc option append		
				eststo clear		
		
			* By state 
		
				tokenize `" "Andhra Pradesh" "Rajasthan" "West Bengal" "'
		
				forv i = 1/3{
					eststo clear
					local regressors `" "sc_cat st_cat" rel_muslim resp_female resp_noschool resp_above60"'
					local j = 1
					foreach var in `regressors'{
						qui svy: regress ad_otpaware_all `var' if state == `i'
						gen sample = e(sample)
						count if (ad_otpaware_all ==.d | ad_otpaware_all ==.r) & state == `i'
						loc miss = r(N)
						count if (ad_otpaware_all ==.e) & state == `i'
						loc errors = r(N)
						
						preserve
						keep if sample == 1
						svy: mean `var'
						if `j++'==1{
							loc x1 = _b[sc_cat] 
							loc x2 = _b[st_cat]
						}
						else{
							loc x1 = _b[`var']
							loc x2 = .
						}
						svy: mean ad_otpaware_all
						loc y1 = _b[ad_otpaware_all]
						eststo: svy: regress ad_otpaware_all `var'
						estadd scalar missing = `miss'
						estadd scalar errors = `errors'
						estadd scalar y = `y1'
						estadd scalar x = `x1'
						estadd scalar z = `x2'
						restore
						drop sample
					}
					local k = `i' + 1
				esttab using "3_General_Usage.rtf", ///
						compress ///
						eqlabels(none) ///
						label ///
						title ("Table 3.13.`k' Hypothesis tests of differences in levels of awareness of OTP authentication for members of different vulnerable communities [State: ``i++'']") ///	
						coeflabels (sc_cat "SC respondent" st_cat "ST respondent" rel_muslim "Muslim respondent" resp_noschool  "Respondent has not attended school" resp_female "Female respondent" resp_above60 "Respondent above age 60") ///
						mtitles ("Aware of OTP" "Aware of OTP" "Aware of OTP" "Aware of OTP" "Aware of OTP" "Aware of OTP" "Aware of OTP") ///
						p ///
						star (* 0.1 ** 0.05 *** 0.01) ///
						lines ///
						b (3) ///
						p (2) ///
						nogaps ///
						stats(N r2 y, fmt(0 3 3) label("Number of observations" "R-squared" "Mean of dependent variable")) ///			nonotes ///
						nonotes ///
						addnotes("Notes: p-values in parentheses, with ***, **, * indicating significance at 1, 5 and 10%. No correction for multiple hypothesis testing has been applied to the results in the table." ///
						"See footnote to Table 3.13.1 for a description of the hypotheses tested here.")	///
						append
						loc option append
				}		
				eststo clear	
			
		
		* Variable: ad_aware_all
		
			* Pooled
			
				eststo clear
				local regressors `" "sc_cat st_cat" rel_muslim resp_female resp_noschool resp_above60"'
				local j = 1
				foreach var in `regressors'{
					qui svy: regress ad_aware_all `var' 
					gen sample = e(sample)
					count if (ad_aware_all ==.d | ad_aware_all ==.r | ad_aware_all == .m) 
					loc miss = r(N)
					count if (ad_aware_all ==.e) 
					loc errors = r(N)
					
					preserve
					keep if sample == 1
					svy: mean `var'
					if `j++'==1{
						loc x1 = _b[sc_cat] 
						loc x2 = _b[st_cat]
					}
					else{
						loc x1 = _b[`var']
						loc x2 = .
					}
					svy: mean ad_aware_all
					loc y1 = _b[ad_aware_all]
					eststo: svy: regress ad_aware_all `var'
					estadd scalar missing = `miss'
					estadd scalar errors = `errors'
					estadd scalar y = `y1'
					estadd scalar x = `x1'
					estadd scalar z = `x2'
					restore
					drop sample
				}
				esttab using "3_General_Usage.rtf", ///
					compress ///
					eqlabels(none) ///
					label ///
					title ("Table 3.14.1 Hypothesis tests of differences in levels of awareness for all authentication mechanisms for members of different vulnerable communities [All three states]") ///	
					coeflabels (sc_cat "SC respondent" st_cat "ST respondent" rel_muslim "Muslim respondent" resp_noschool  "Respondent has not attended school" resp_female "Female respondent" resp_above60 "Respondent above age 60") ///
					mtitles ("Aware of all" "Aware of all" "Awareness of all " "Aware of all" "Aware of all" "Aware of all") ///
					p ///
					star (* 0.1 ** 0.05 *** 0.01) ///
					lines ///
					b (3) ///
					p (2) ///
					nogaps ///
					stats(N r2 y, fmt(0 3 3) label("Number of observations" "R-squared" "Mean of dependent variable")) ///			nonotes ///
					nonotes ///
					addnotes("Notes: p-values in parentheses, with ***, **, * indicating significance at 1, 5 and 10%. No correction for multiple hypothesis testing has been applied to the results in the table." ///
					"We test the null hypotheses that there are no differences in the likelihood of being aware of all authentication mechanisms between vulnerable respondents and other respondents, with vulnerability being proxied by each of the categories above. Each column presents coefficients from a regression of the outcome variable on a dummy variable for the corresponding category and a constant. Hence we separately examine whether each individual type above has a different likelihood of being aware of all authentication mechanisms compared to all other individuals (i.e. all those not in the specified type).")	///
					append
					loc option append
				eststo clear	
		
			* By state 
		
				tokenize `" "Andhra Pradesh" "Rajasthan" "West Bengal" "'
				forv i = 1/3{
					eststo clear
					local regressors `" "sc_cat st_cat" rel_muslim resp_female resp_noschool resp_above60"'
					local j = 1
					foreach var in `regressors'{
						qui svy: regress ad_aware_all `var' if state == `i'
						gen sample = e(sample)
						count if (ad_aware_all ==.d | ad_aware_all ==.r | ad_aware_all == .m) & state == `i'
						loc miss = r(N)
						count if (ad_aware_all ==.e) & state == `i'
						loc errors = r(N)
						
						preserve
						keep if sample == 1
						svy: mean `var'
						if `j++'==1{
							loc x1 = _b[sc_cat] 
							loc x2 = _b[st_cat]
						}
						else{
							loc x1 = _b[`var']
							loc x2 = .
						}
						svy: mean ad_aware_all
						loc y1 = _b[ad_aware_all]
						eststo: svy: regress ad_aware_all `var'
						estadd scalar missing = `miss'
						estadd scalar errors = `errors'
						estadd scalar y = `y1'
						estadd scalar x = `x1'
						estadd scalar z = `x2'
						restore
						drop sample
					}
					local k = `i' + 1
				esttab using "3_General_Usage.rtf", ///
						compress ///
						eqlabels(none) ///
						label ///
						title ("Table 3.14.`k' Hypothesis tests of differences in levels of awareness for all authentication mechanisms for members of different vulnerable communities [State: ``i++'']") ///	
						coeflabels (sc_cat "SC respondent" st_cat "ST respondent" rel_muslim "Muslim respondent" resp_noschool  "Respondent has not attended school" resp_female "Female respondent" resp_above60 "Respondent above age 60") ///
						mtitles ("Aware of all" "Aware of all" "Awareness of all " "Aware of all" "Aware of all" "Aware of all") ///
						p ///
						star (* 0.1 ** 0.05 *** 0.01) ///
						lines ///
						b (3) ///
						p (2) ///
						nogaps ///
						stats(N r2 y, fmt(0 3 3) label("Number of observations" "R-squared" "Mean of dependent variable")) ///			nonotes ///
						nonotes ///
						addnotes("Notes: p-values in parentheses, with ***, **, * indicating significance at 1, 5 and 10%. No correction for multiple hypothesis testing has been applied to the results in the table." ///
						"See footnote to Table 3.14.1 for a description of the hypotheses tested here.")	///
						append
						loc option append
				}		
				eststo clear	
		
